﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;

namespace JMT.Data
{
    public interface IJContainer
    {
        void Add(IJModel jModel);
        void Remove(IJModel jModel);
        IJModel Get(Guid id);
        List<IJModel> ToList();
    }

    public interface IJContainer<T> where T : IJModel
    {
        //event JCollectionChangedEventHandler<T> JCollectionChanged;
        void Add(T jModel);
        void Remove(T jModel);
        T Get(Guid id);
        List<T> ToList();

        void Register(JContainerUpdate<T> update);
    }

    public delegate void JContainerUpdate<T>(object sender, JUpdateEventArgs<T> e);

    public class JUpdateEventArgs<T>
    {
        public NotifyCollectionChangedAction Action { get; set; }
        public IList<T> NewItems { get; set; }
        public int NewStartingIndex { get; set; }
        public IList<T> OldItems { get; set; }
        public int OldStartingIndex { get; set; }
    }
}
